package com.runnor.common.websys.system.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.BooleanEnum;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;

/**
 * @TableName sys_log
 */
@TableName(value = "sys_log")
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
@HeadFontStyle(fontHeightInPoints = 12, bold = BooleanEnum.TRUE)
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER)
@ContentStyle(
        wrapped = BooleanEnum.FALSE,
        dataFormat = 49,
        verticalAlignment = VerticalAlignmentEnum.CENTER,
        borderTop = BorderStyleEnum.THIN,
        borderBottom = BorderStyleEnum.THIN,
        borderLeft = BorderStyleEnum.THIN,
        borderRight = BorderStyleEnum.THIN,
        horizontalAlignment = HorizontalAlignmentEnum.LEFT
)
public class SysLog implements Serializable {
    /**
     * 序号
     */
    @ColumnWidth(10)
    @ExcelProperty(value = "序号", index = 0)
    @TableId
    private String id;

    /**
     * 用户IP
     */
    @ExcelProperty(value = "用户IP", index = 1)
    private String remoteAddr;

    /**
     * 请求路径
     */
    @ExcelProperty(value = "请求路径", index = 2)
    private String httpPath;

    /**
     * 请求方法
     */
    @ColumnWidth(11)
    @ExcelProperty(value = "请求方法", index = 3)
    private String httpMethod;


    /**
     * 访问时间
     */
    @ColumnWidth(16)
    @ExcelProperty(value = "访问时间", index = 4)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private String accessTime;

    /**
     * 处理用时
     */
    @ColumnWidth(11)
    @ExcelProperty(value = "处理时长", index = 5)
    private Integer cost;

    /**
     * 客户端
     */
    @ExcelProperty(value = "客户端", index = 6)
    private String userAgent;

    /**
     * 用户id
     */
    @ExcelIgnore
    private String userid;

    /**
     * 用户账号
     */
    @ExcelProperty(value = "账号名称", index = 7)
    private String username;

    /**
     * 请求方法名
     */
    @ExcelProperty(value = "请求方法名", index = 8)
    private String javaMethodName;

    /**
     * 请求参数
     */
    @ExcelIgnore
    private String reqParam;

    /**
     * 响应参数
     */
    @ExcelIgnore
    private String respData;

    /**
     * 异常信息
     */
    @ColumnWidth(11)
    @ExcelProperty(value = "处理状态", index = 9)
    private String exception;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    @ExcelIgnore
    @TableField(exist = false)
    private String[] date;

}